﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliBiliCSharpStudy.old {
    /**
     * 关系运算符
     */
    class RelationalOperatorDemo {
        public static void demo() {
            //test1();
            //test2();
            //test3();
            //test4();
            test5();
        }

        public static void test5() {
            object o = new Teacher();
            if (o is Teacher) {
                ((Teacher)o).Teach();
            }
            if (o is Teacher) {
                (o as Teacher).Teach();
            }
        }

        // is
        public static void test4() {
            Teacher t = null;
            var result = t is Teacher;
            Console.WriteLine(result.GetType().FullName);
            Console.WriteLine(result);
            t = new Teacher();
            result = t is Teacher;
            Console.WriteLine(result.GetType().FullName);
            Console.WriteLine(result);
            result = t is Human;
            Console.WriteLine(result);
            result = t is Animal;
            Console.WriteLine(result);
            result = t is Car;
            Console.WriteLine(result);
        }

        // 字符串的比较
        public static void test3() {
            string str1 = "abc";
            string str2 = "Abc";
            Console.WriteLine(str1 == str2);
            Console.WriteLine(str1.ToLower() == str2.ToLower());
        }

        // char 字符的比较
        public static void test2() {
            char char1 = 'a';
            char char2 = 'A';
            var result = char1 < char2;
            Console.WriteLine(result.GetType().FullName);
            Console.WriteLine(result);
            ushort u1 = (ushort)char1;
            ushort u2 = (ushort)char2;
            Console.WriteLine(char1 + ", " + u1);
            Console.WriteLine(char2 + ", " + u2);
        }

        public static void test1() {
            int x = 5;
            double y = 4.5;
            var z = x > y;
            Console.WriteLine(z.GetType().FullName);
            Console.WriteLine(z);
        }
    }

    class Car {
        public void Run() {
            Console.WriteLine("car run...");
        }
    }
}
